{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _objectWithoutPropertiesLoose from \"@babel/runtime/helpers/esm/objectWithoutPropertiesLoose\";\nconst _excluded = [\"getRootProps\"];\nimport { useTabContext, getTabId, getPanelId } from '../TabsUnstyled';\nimport { useButton } from '../ButtonUnstyled';\nconst useTab = parameters => {\n  var _getPanelId, _getTabId;\n  const {\n    value: valueProp,\n    onChange,\n    onClick,\n    onFocus\n  } = parameters;\n  const _useButton = useButton(parameters),\n    {\n      getRootProps: getRootPropsButton\n    } = _useButton,\n    otherButtonProps = _objectWithoutPropertiesLoose(_useButton, _excluded);\n  const context = useTabContext();\n  if (context === null) {\n    throw new Error('No TabContext provided');\n  }\n  const value = valueProp != null ? valueProp : 0;\n  const selected = context.value === value;\n  const selectionFollowsFocus = context.selectionFollowsFocus;\n  const a11yAttributes = {\n    role: 'tab',\n    'aria-controls': (_getPanelId = getPanelId(context, value)) != null ? _getPanelId : undefined,\n    id: (_getTabId = getTabId(context, value)) != null ? _getTabId : undefined,\n    'aria-selected': selected,\n    disabled: otherButtonProps.disabled\n  };\n  const createHandleFocus = otherHandlers => event => {\n    var _otherHandlers$onFocu;\n    (_otherHandlers$onFocu = otherHandlers.onFocus) == null ? void 0 : _otherHandlers$onFocu.call(otherHandlers, event);\n    if (event.defaultPrevented) {\n      return;\n    }\n    if (selectionFollowsFocus && !selected) {\n      if (onChange) {\n        onChange(event, value);\n      }\n      context.onSelected(event, value);\n    }\n    if (onFocus) {\n      onFocus(event);\n    }\n  };\n  const createHandleClick = otherHandlers => event => {\n    var _otherHandlers$onClic;\n    (_otherHandlers$onClic = otherHandlers.onClick) == null ? void 0 : _otherHandlers$onClic.call(otherHandlers, event);\n    if (event.defaultPrevented) {\n      return;\n    }\n    if (!selected) {\n      if (onChange) {\n        onChange(event, value);\n      }\n      context.onSelected(event, value);\n    }\n    if (onClick) {\n      onClick(event);\n    }\n  };\n  const getRootProps = function () {\n    let otherHandlers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n    const buttonResolvedProps = getRootPropsButton(_extends({}, otherHandlers, {\n      onClick: createHandleClick(otherHandlers),\n      onFocus: createHandleFocus(otherHandlers)\n    }));\n    return _extends({}, buttonResolvedProps, a11yAttributes);\n  };\n  return _extends({\n    getRootProps\n  }, otherButtonProps, {\n    selected\n  });\n};\nexport default useTab;","map":{"version":3,"names":["_extends","_objectWithoutPropertiesLoose","_excluded","useTabContext","getTabId","getPanelId","useButton","useTab","parameters","_getPanelId","_getTabId","value","valueProp","onChange","onClick","onFocus","_useButton","getRootProps","getRootPropsButton","otherButtonProps","context","Error","selected","selectionFollowsFocus","a11yAttributes","role","undefined","id","disabled","createHandleFocus","otherHandlers","event","_otherHandlers$onFocu","call","defaultPrevented","onSelected","createHandleClick","_otherHandlers$onClic","buttonResolvedProps"],"sources":["/data/messenger.client/node_modules/@mui/lab/node_modules/@mui/base/TabUnstyled/useTab.js"],"sourcesContent":["import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _objectWithoutPropertiesLoose from \"@babel/runtime/helpers/esm/objectWithoutPropertiesLoose\";\nconst _excluded = [\"getRootProps\"];\nimport { useTabContext, getTabId, getPanelId } from '../TabsUnstyled';\nimport { useButton } from '../ButtonUnstyled';\nconst useTab = parameters => {\n  var _getPanelId, _getTabId;\n  const {\n    value: valueProp,\n    onChange,\n    onClick,\n    onFocus\n  } = parameters;\n  const _useButton = useButton(parameters),\n    {\n      getRootProps: getRootPropsButton\n    } = _useButton,\n    otherButtonProps = _objectWithoutPropertiesLoose(_useButton, _excluded);\n  const context = useTabContext();\n  if (context === null) {\n    throw new Error('No TabContext provided');\n  }\n  const value = valueProp != null ? valueProp : 0;\n  const selected = context.value === value;\n  const selectionFollowsFocus = context.selectionFollowsFocus;\n  const a11yAttributes = {\n    role: 'tab',\n    'aria-controls': (_getPanelId = getPanelId(context, value)) != null ? _getPanelId : undefined,\n    id: (_getTabId = getTabId(context, value)) != null ? _getTabId : undefined,\n    'aria-selected': selected,\n    disabled: otherButtonProps.disabled\n  };\n  const createHandleFocus = otherHandlers => event => {\n    var _otherHandlers$onFocu;\n    (_otherHandlers$onFocu = otherHandlers.onFocus) == null ? void 0 : _otherHandlers$onFocu.call(otherHandlers, event);\n    if (event.defaultPrevented) {\n      return;\n    }\n    if (selectionFollowsFocus && !selected) {\n      if (onChange) {\n        onChange(event, value);\n      }\n      context.onSelected(event, value);\n    }\n    if (onFocus) {\n      onFocus(event);\n    }\n  };\n  const createHandleClick = otherHandlers => event => {\n    var _otherHandlers$onClic;\n    (_otherHandlers$onClic = otherHandlers.onClick) == null ? void 0 : _otherHandlers$onClic.call(otherHandlers, event);\n    if (event.defaultPrevented) {\n      return;\n    }\n    if (!selected) {\n      if (onChange) {\n        onChange(event, value);\n      }\n      context.onSelected(event, value);\n    }\n    if (onClick) {\n      onClick(event);\n    }\n  };\n  const getRootProps = (otherHandlers = {}) => {\n    const buttonResolvedProps = getRootPropsButton(_extends({}, otherHandlers, {\n      onClick: createHandleClick(otherHandlers),\n      onFocus: createHandleFocus(otherHandlers)\n    }));\n    return _extends({}, buttonResolvedProps, a11yAttributes);\n  };\n  return _extends({\n    getRootProps\n  }, otherButtonProps, {\n    selected\n  });\n};\nexport default useTab;"],"mappings":"AAAA,OAAOA,QAAQ,MAAM,oCAAoC;AACzD,OAAOC,6BAA6B,MAAM,yDAAyD;AACnG,MAAMC,SAAS,GAAG,CAAC,cAAc,CAAC;AAClC,SAASC,aAAa,EAAEC,QAAQ,EAAEC,UAAU,QAAQ,iBAAiB;AACrE,SAASC,SAAS,QAAQ,mBAAmB;AAC7C,MAAMC,MAAM,GAAGC,UAAU,IAAI;EAC3B,IAAIC,WAAW,EAAEC,SAAS;EAC1B,MAAM;IACJC,KAAK,EAAEC,SAAS;IAChBC,QAAQ;IACRC,OAAO;IACPC;EACF,CAAC,GAAGP,UAAU;EACd,MAAMQ,UAAU,GAAGV,SAAS,CAACE,UAAU,CAAC;IACtC;MACES,YAAY,EAAEC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